﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynaPrecision.RandomNumberGenerator
{
	public class Cauchy<T> : IRandomNumberGenerator<T>
	{
		public Cauchy()
		{
			Mean = DefaultValueProvider<T>.Zero;
			Scale = DefaultValueProvider<T>.GetValueFromInteger(1);
		}
		public T Mean { get; set; }
		public T Scale { get; set; }
		public T Next()
		{
			return DynamicCastOperator.Add<T,T,T>(Mean,  
				DynamicCastOperator.Multiply<T,T,T>(
				DynamicCastOperator.CastToFunctor<double, double, T>(Math.Tan,
				SingletonUniformRandomProvider.NextDouble() * Math.PI), Scale));
		}
	}
}
